//
//  MessageListViewController.m
//  1gene
//
//  Created by 1jiyin on 16/5/5.
//  Copyright © 2016年 1jiyin. All rights reserved.
//

#import "MessageListViewController.h"
#import "CommunityChatViewController.h"
@interface MessageListViewController ()

@end

@implementation MessageListViewController

- (void)viewDidLoad {
    //重写显示相关的接口，必须先调用super，否则会屏蔽SDK默认的处理
    [super viewDidLoad];
    self.view.backgroundColor=[UIColor whiteColor];
    //设置需要显示哪些类型的会话
    [self setDisplayConversationTypes:@[@(ConversationType_PRIVATE),
                                        @(ConversationType_DISCUSSION),
                                        @(ConversationType_CHATROOM),
                                        @(ConversationType_GROUP),
                                        @(ConversationType_APPSERVICE),
                                        @(ConversationType_SYSTEM)]];
    //设置需要将哪些类型的会话在会话列表中聚合显示
    [self setCollectionConversationType:@[@(ConversationType_DISCUSSION),
                                          @(ConversationType_GROUP)]];
    
    [self createNavigation];
    self.emptyConversationView=[self createNoMessageView];
    // Do any additional setup after loading the view.
}
//重写RCConversationListViewController的onSelectedTableRow事件
- (void)onSelectedTableRow:(RCConversationModelType)conversationModelType
         conversationModel:(RCConversationModel *)model
               atIndexPath:(NSIndexPath *)indexPath {
    CommunityChatViewController *conversationVC = [[CommunityChatViewController alloc]init];
    conversationVC.conversationType = model.conversationType;
    conversationVC.targetId = model.targetId;
    conversationVC.title = @"会话";
    self.tabBarController.tabBar.hidden=YES;
    [self.navigationController pushViewController:conversationVC animated:YES];
}

-(void)createNavigation
{
    self.tabBarController.tabBar.hidden=YES;
    self.navigationController.navigationBar.hidden=NO;
    self.navigationController.navigationBar.barTintColor=[UIColor colorWithRed:84/255.0 green:199/255.0 blue:222/255.0 alpha:1];
    //返回
    UIButton *leftBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    leftBtn.frame=CGRectMake(0, 0, 25, 25);
    [leftBtn setBackgroundImage:[UIImage imageNamed:@"left_back"] forState:UIControlStateNormal];
    [leftBtn addTarget:self action:@selector(leftBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc]initWithCustomView:leftBtn];
    
    //标题
    UILabel *title=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 44)];
    title.text=@"消息列表";
    title.font=[UIFont systemFontOfSize:22];
    title.textAlignment=NSTextAlignmentCenter;
    title.textColor=[UIColor whiteColor];
    self.navigationItem.titleView=title;
}
//返回上一页
-(void)leftBtnClick:(UIButton *)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



-(UIView *)createNoMessageView
{
    UIView *myView=[[UIView alloc]initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, self.view.frame.size.height-64)];
    myView.backgroundColor=[UIColor whiteColor];
    
    
    UILabel *lab=[[UILabel alloc]init];
    lab.bounds=CGRectMake(0, 0, 200, 30);
    lab.center=CGPointMake(self.view.center.x, self.view.center.y);
    lab.text=@"亲，你还有收到消息哟!";
    lab.font=[UIFont systemFontOfSize:13];
    lab.textColor=[UIColor blackColor];
    lab.textAlignment=NSTextAlignmentCenter;
    //lab.backgroundColor=[UIColor grayColor];
    [myView addSubview:lab];
    
    //未收到消息图片
    UIImageView *imgView=[[UIImageView alloc]initWithFrame:CGRectMake(lab.frame.origin.x+30, lab.frame.origin.y-155, 140, 155)];
    imgView.image=[UIImage imageNamed:@"receiveMessage_no"];
    [myView addSubview:imgView];
    
    return myView;
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
